<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>await</title>
</head>
<body>
    <script>
        async function main(){
            //1. 如果 await 右侧为非 promise 类型数据
            var rs = await 20;
            var rs = await 1+1;
            var rs = await '6+7';
            //2. 如果 await 右侧为 promise 类型数据
            var rs = await new Promise((resolve, reject) => {
                resolve('成功的数据');
            });
            //3. promise 如果失败啦
            try{
                var rs = await new Promise((resolve, reject) => {
                    reject('失败啦!!状态为 103')
                });
            }catch(e){
                console.log(e);
            }
        }

        main();

    </script>
</body>
</html>